package com.zy.pool.domain;

import lombok.*;

/**
*  com.zy.pool.domain DBbean
*@Description:  连接池属性对象
*@date: 16:14 2018/2/6
*@author: zhaoliang.fu
*/

public class DBbean {

    /**
     * 驱动名称
     */
    @NonNull
    @Getter
    @Setter
    private String driverName;

    @NonNull
    @Getter
    @Setter
    private String url;

    @NonNull
    @Getter
    @Setter
    private String userName;

    @NonNull
    @Getter
    @Setter
    private String password;

    /**
     * 连接池名字
     */
    @Getter
    @Setter
    private String poolName;

    /**
     * 空闲池，最小连接数
     */
    @Getter
    @Setter
    private Integer minConnections;

    /**
     * 最大连接池
     */
    @Getter
    @Setter
    private Integer maxConnections;

    /**
     * 初始化连接数
     */
    @Getter
    @Setter
    private Integer initConnections;

    /**
     * 重复连接频率
     */
    @Getter
    @Setter
    private Integer connTimeOut;

    /**
     * 最大允许连接数，和数据库对应
     */
    @Getter
    @Setter
    private Integer maxActiveConnections;

    /**
     * 连接超时时间
     * 默认20分钟
     */
    @Getter
    @Setter
    private Long connectionTimeOut;

    /**
     * 是否获得当前连接，默认true
     */
    @Getter
    @Setter
    private Boolean isCurrentConnection;

    /**
     * 是否定时检查连接池
     */
    @Getter
    @Setter
    private Boolean isCheckPool;

    /**
     * 检查频率
     */
    @Getter
    @Setter
    private Long periodCheck;

    /**
     * 延迟多少时间后开始 检查
     */
    @Getter
    @Setter
    private Long lazyCheck;

    public DBbean(String driverName, String url, String userName, String password) {
        this.driverName = driverName;
        this.url = url;
        this.userName = userName;
        this.password = password;
        init();
    }

    public DBbean() {
    }

    private void init(){
        this.poolName="DefaultConnectionPool";
        this.minConnections=1;
        this.maxConnections=10;
        this.initConnections=5;
        this.connTimeOut=1000;
        this.maxActiveConnections=100;
        this.connectionTimeOut=Long.valueOf(1000*60*20);
        this.isCurrentConnection=Boolean.TRUE;
        this.isCheckPool=Boolean.TRUE;
        this.lazyCheck=Long.valueOf(1000*60*60);
        this.periodCheck=Long.valueOf(1000*60*60);
    }


}
